package top.misspro.valheimadminsocket.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import top.misspro.valheimadminsocket.message.Action;
import top.misspro.valheimadminsocket.message.command.Install;
import top.misspro.valheimadminsocket.server.Client;
import top.misspro.valheimadminsocket.server.ServerContains;
import top.misspro.valheimadminsocket.service.GameService;
import top.misspro.valheimadminsocket.util.ChannelUtils;

/**
 * @author liulinbo
 */
@Slf4j
public class InstallEventListener implements ServerEventListener {

    @Autowired
    private GameService gameService;

    @Override
    public void handle(Client client, String data) {
        log.info("客户端安装 {}", data);
        if (client.getStatus() == ServerContains.ServerStatus.UN_CONNECT) {
            ChannelUtils.sendToClient(client.getChannel(), Action.Client.FAILED, null, "服务器未连接");
            return;
        }
        Install install = new Install(client.getServerInfo());
//        gameService.install(install);
        ChannelUtils.sendToClient(client.getChannel(), Action.Client.OK, null, "安装成功");
    }
}
